#define LED_PIN 10 // Change this to your connected LED pin void setup() { Serial.begin(115200); // Start serial communication pinMode(LED_PIN, OUTPUT); digitalWrite(LED_PIN, LOW); // Ensure LED is off initially } void loop() { if (Serial.available()) { String command = Serial.readStringUntil('\n'); // Read until newline command.trim(); // Remove any trailing whitespace if (command == "ON") { digitalWrite(LED_PIN, HIGH); } else if (command == "OFF") { digitalWrite(LED_PIN, LOW); } } }